#ifndef __SCENE_EDITOR_PLUGIN_H__
#define __SCENE_EDITOR_PLUGIN_H__


#include "EditorPlugin.h"


class SceneEditorPlugin
        : public QObject
        , public EditorPlugin
{
    Q_OBJECT
    Q_INTERFACES(EditorPlugin)
    Q_PLUGIN_METADATA(IID EDITOR_PLUGIN_IID FILE "../json/SceneEditorPlugin.json")

public:
    SceneEditorPlugin();
    virtual ~SceneEditorPlugin();

protected:
    QString name() const;
    uint pluginID() const;

    bool onCreateProject(const QString &projPath);
    bool onOpenProject(const QString &projPath, QTreeWidgetItem *parent);
    bool onCloseProject();

    int onCreateFile(const QString &name);
    EditorWindow *onOpenFile(const QString &fileName, QWidget *parent, int userType, bool &exists);
    bool onCloseFile();

    void onRefresh();

    QIcon *icon();
    QString fileExtension() const;
    QString fileFolder() const;

    bool onExport(Packer *packer);
    bool onImport(Unpacker *unpacker);

    void populate(QTreeWidgetItem *parent);
    void populate(QTreeWidgetItem *parent, const QString &location, const QString &filter = "");

    QTreeWidgetItem *createTreeItem(const QString &title, const QString &ext, QTreeWidgetItem *parent = 0);

public slots:
    void onCloseEditor(EditorWindow *editor);

private:
    uint    mPluginID;
    QIcon   *mIcon;

    int     mTreeItemID;

    QTreeWidgetItem *mSceneRoot;
    QTreeWidgetItem *mImageRoot;

    QString mProjPath;

    typedef QMap<QString, EditorWindow*>    WindowMap;
    typedef WindowMap::iterator             WindowMapItr;

    WindowMap   mWindows;
};


#endif  /*__SCENE_EDITOR_PLUGIN_H__*/
